package io.cloud.tec.ant_design_vue_pro.web;

import io.cloud.tec.ant_design_vue_pro.biz.AccountLoginInfoService;
import io.cloud.tec.ant_design_vue_pro.dto.LoginReqDTO;
import io.cloud.tec.ant_design_vue_pro.dto.LoginRespDTO;
import io.cloud.tec.project.util.JsonUtils;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("api/auth")
@AllArgsConstructor
public class AuthWeb {

    AccountLoginInfoService accountLoginInfoService;

    @PostMapping("login")
    LoginRespDTO login(@RequestBody LoginReqDTO loginReqDTO) {
        log.info("{}", loginReqDTO);
        accountLoginInfoService.validateLoginInfo(loginReqDTO);
        return new LoginRespDTO();
    }

    @PostMapping("logout")
    void logout() {
    }

    @PostMapping("twoStepCode")
    Map twoStepCode() {
        Map map = new HashMap<>();
        map.put("stepCode", Math.random());
        log.info("result: {}", JsonUtils.toJsonString(map));
        return map;
    }


    @GetMapping("concurrentBatchInsert")
    void concurrentBatchInsert() {
        accountLoginInfoService.batchInsert();
    }
}
